package se.cambio.system.rms.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import se.cambio.system.rms.dao.HospitalDao;
import se.cambio.system.rms.entity.Hospital;

public class HospitalDaoImpl extends HibernateDaoSupport implements HospitalDao {
	public void save(Hospital stock){
		getHibernateTemplate().save(stock);
	}
	
	public void update(Hospital stock){
		getHibernateTemplate().update(stock);
	}
	
	public void delete(Hospital stock){
		getHibernateTemplate().delete(stock);
	}
	
	public Hospital findByHospitalId(String id){
		List list = getHibernateTemplate().find("from Hospital where latest = 1 and active=1 and id=?",id);
		if(list.size() > 0){
			return (Hospital)list.get(0);
		}
		else
			throw new NullPointerException();
	}
}
